package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    static {
        System.loadLibrary("myapplication");
    }

    private ListView listView;
    private GpioAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listView = findViewById(R.id.listView);
        adapter = new GpioAdapter(this);
        listView.setAdapter(adapter);

        adapter.addItem();

        Button addButton = findViewById(R.id.addButton);
        addButton.setOnClickListener(v -> adapter.addItem());

    }

    // Native methods
    public native void setGpioValue(int gpioNum, int value);
    public native int getGpioValue(int gpioNum);
}